<template>
    <!-- 标题区域 -->
    <van-nav-bar title="订单详情" fixed></van-nav-bar>
    <div style="height: 45px;"></div>
    <van-address-list v-model="chosenAddressId" :list="list" :disabled-list="disabledList" default-tag-text="默认"
        @add="onAdd" @edit="onEdit" add-button-text="去支付" @click="goPay" />
    <van-cell-group inset>
        <van-cell title="下单时间" :value="orderdetailApiData.create_time" />
        <van-cell title="订单号" :value="orderdetailApiData.orderId" />
        <van-cell title="收货人" :value="orderdetailApiData.username" />
        <van-cell title="订单总价" :value="(orderdetailApiData.totalPrice / 100 / 100).toFixed(2)" />
        <van-cell title="订单描述" :value="orderdetailApiData.product_code" />
    </van-cell-group>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
console.log(route.params.orderId)
import { orderdetailApi } from '@/api/api'
let orderdetailApiData = ref([])
orderdetailApi(route.params.orderId).then(res => {
    console.log('订单详情', res)
    orderdetailApiData.value = res.data.data
    payApiData.value = {
        orderId : res.data.data.orderId,
        subject : res.data.data.product_code,
        totalPrice : res.data.data.totalPrice / 100 / 100
    }

})
const chosenAddressId = ref('1');
const list = [
    {
        id: '1',
        name: '张三',
        tel: '13000000000',
        address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
        isDefault: true,
    },
];
import { payApi } from '@/api/api'
let payApiData = ref([])
const goPay = () => {
    payApi(payApiData.value).then(res => {
        console.log('支付数据', res)
        window.open(res.data.data, '_blank')
    })
}
</script>

<style lang="scss" scoped></style>